package com.yonghui.springsecurityoauth2demo.pojo;

/**
 * @author he_jiebing@jiuyv.com
 * @create 2024-05-17 15:26
 */
public class ResultVo<T> {

    private Integer code;
    private String msg;

    private T data;

    public ResultVo() {

    }

    public ResultVo(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static ResultVo resultSuccess(Object accessToken) {
        ResultVo vo = new ResultVo();
        vo.setCode(200);
        vo.setMsg("success");
        vo.setData(accessToken);
        return vo;
    }

    public static ResultVo resultFail(String fail) {
        ResultVo vo = new ResultVo();
        vo.setCode(500);
        vo.setMsg("fail");
        vo.setData(fail);
        return vo;
    }
    public static ResultVo resultFail(ResultCode resultCode) {
        ResultVo vo = new ResultVo();
        vo.setCode(resultCode.getCode());
        vo.setMsg(resultCode.getMsg());
        //vo.setData(fail);
        return vo;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
